package com.koushikdutta.async;

import com.koushikdutta.async.slice.MainAbilitySlice;
import com.koushikdutta.async.utils.Delivery;
import com.koushikdutta.async.utils.PermissionsUtils;
import com.koushikdutta.async.utils.Toast;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

import static com.koushikdutta.async.utils.PermissionsUtils.REQUEST_WRITE_CODE;

/**
 * 打发士大夫
 */
public class MainAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());

        //权限
        Delivery.getInstance().postDelayed(new Runnable() {
            @Override
            public void run() {
                PermissionsUtils.getWritePermission(getContext());
            }
        }, 1000);
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
            case REQUEST_WRITE_CODE:
                Toast.show(getContext(),"权限请求成功！！！");
                break;
        }
    }
}
